home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / u_chk.arc / USERIS.C < prev    next >
Text File  |  1989-12-17  |  6KB  |  260 lines

  1.  
  2.  /*
  3.  
  4.  John T. McCann, NOVUSER Wizard SysOp, 70007,3430
  5.  1/5/89
  6.  
  7.  Written in Turbo C v2.0
  8.  
  9.  This program will, given a command line argument, verify a user's
  10.  login name on the current file server, ex:
  11.  
  12.  USERIS JOHN
  13.  
  14.  if JOHN is a valid LOGIN NAME (for a user) on the current file server
  15.  a DOS ERRORLEVEL of 0 is returned
  16.  
  17.  if not valid, a DOS ERRORLEVEL of 1 is returned
  18.  
  19.  if no command line arguement is entered 2 is returned
  20.  
  21.  if not logged into any file servers (but the shell is loaded)
  22.  3 is returned
  23.  
  24.  if the shell is not loaded 4 is returned
  25.  
  26.  */
  27.  
  28.  
  29.  
  30.  
  31. #define inc          "UserIs, (c)1989 Wizard Stuff"
  32. #define Version      1.0
  33.  
  34.  
  35. typedef union {
  36.         struct {
  37.                  unsigned int Ax, Bx, Cx, Dx, Bp, Si, Di, Ds, Es, FLAGS;
  38.                } F;
  39.         struct {
  40.                  unsigned char Al, Ah, Bl, Bh, Cl, Ch, Dl, Dh;
  41.                } H;
  42.               } Registers;
  43.  
  44. typedef struct {
  45.                  unsigned char ah, al, bh, bl;
  46.                }  Longs;
  47.  
  48. typedef struct {
  49.              char         wh, wl;
  50.                }  MyWord;
  51.  
  52. typedef struct {
  53.              MyWord       Native;
  54.          char         func;  /*  $36 for get object name  */
  55.              Longs        unique;/*  Unique ID for the object */
  56.              }  e336cl;
  57.  
  58. typedef struct {
  59.              MyWord       Native;
  60.              Longs        id;     /*  same id as above  */
  61.          MyWord       ObjTyp; /*  type of object    */
  62.              char         Name[47];
  63.              }  e336rp;
  64.  
  65. typedef struct {
  66.               MyWord       Native;
  67.               char         Func;  /*  $46 = get my bindery access level */
  68.              }  chkcall;
  69.  
  70. typedef struct {
  71.               MyWord       Native;
  72.               char         Mask;
  73.               Longs        id;
  74.              }  chkrply;
  75.  
  76. typedef struct {
  77.               MyWord       Native;
  78.               char         Func;  /*  55 for Search for Users  */
  79.           Longs        last;  /*  make it -1  */
  80.               MyWord       ObjTyp;  /*  Search for users 0001  */
  81.               char         ObjNml;  /*  1  */
  82.               char         ObjNme[47];  /*  *, if search all is used  */
  83.              }  e33dcall;
  84.  
  85. typedef struct {
  86.               MyWord       Native;
  87.               Longs        Id;
  88.               MyWord       ObjectType;
  89.               char         PropName[47];
  90.                 /*  could add some space down here since I tell it the reply buffer
  91.                 is 255 bytes long, but, that really isn't going to happen... */
  92.              }  e33drply;
  93.  
  94.  
  95. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  96. #define Seg(ptr) _DS
  97. #define Ofs(ptr) (unsigned)(ptr)
  98. #else
  99. #define Ofs(fp)      ((unsigned)(fp))
  100. #define Seg(fp)      ((unsigned)((unsigned long)(fp) >> 16))
  101. #endif
  102.  
  103. #define MsDos intr
  104.  
  105. #define length(s) strlen(s)
  106.  
  107. Registers    Regs;
  108.  
  109. chkcall      cc;
  110. chkrply      cr;
  111. e336cl       nc;
  112. e336rp       nr;
  113. e33dcall     pc;
  114. e33drply     pr;
  115. int          a;
  116.  
  117.  
  118. void         UserI(argv)
  119. char *argv[];
  120. {
  121. char         PS[80];  /*  just a string to hold the paramstr(1) variable  */
  122.  
  123.  
  124. /* NOTE I had used 1f on next line (last.ah), it is now ff, it is SUPPOSE to be ff, sorry
  125.    for any inconvenience this may cause, if you use 1f it will be a problem
  126.    with netware 386 */
  127.  
  128.  
  129.   pc.last.ah = 0xff;   /*  set the last object seen to -1  */
  130.   pc.last.al = 0xff;
  131.   pc.last.bh = 0xff;
  132.   pc.last.bl = 0xff;
  133.  
  134.   pr.Native.wl = 0x00;
  135.   pr.Native.wh = 0xFF;/*  set up reply buffer size, note it really isn't 255
  136.               bytes long, but neither is the possible reply... */
  137.  
  138.   pc.Native.wl = 0x00;
  139.   pc.Native.wh = 0x8 + length(argv[1]);   /*  set up length of request buffer  */
  140.  
  141.  
  142.   pc.Func = 0x37;   /*  scan bindery objects  */
  143.  
  144.   pc.ObjTyp.wh = 0;
  145.   pc.ObjTyp.wl = 1;   /*  01 = user object type  */
  146.  
  147.   pc.ObjNml = length(argv[1]);
  148.  
  149.   strcpy(PS, argv[1]);
  150.   for (a = 0; a <= (pc.ObjNml % 48); a++)
  151.    {
  152.     if ( (PS[a]>96) && (PS[a]<123) ) PS[a] = PS[a] - 32;
  153.        /* convert to Upper Case */
  154.     pc.ObjNme[a] = PS[a];
  155.    }
  156.  
  157.   Regs.F.Ax = 0xE300;
  158.  
  159.   Regs.F.Es = Seg(&pr);
  160.   Regs.F.Di = Ofs(&pr);
  161.  
  162.   Regs.F.Ds = Seg(&pc);
  163.   Regs.F.Si = Ofs(&pc);
  164.  
  165.   MsDos(33,&Regs);
  166.  
  167.  
  168.   if (Regs.H.Al == 0) exit(0);else exit(1);
  169.  
  170. }
  171.   /*  of Proc UserI  */
  172.  
  173.  
  174.  
  175. void         Will_It_Run()
  176. {
  177.  
  178.     Regs.F.Ax = 0xE300;
  179.  
  180.     cc.Native.wl = 0x00;
  181.     cc.Native.wh = 0x01;
  182.     cr.Native.wl = 0x00;
  183.     cr.Native.wh = 0xff;
  184.     cc.Func = 0x46;
  185.     cr.Mask = 0x00;
  186.     cr.id.al = 0x00;
  187.     cr.id.ah = 0x00;
  188.     cr.id.bl = 0x00;
  189.     cr.id.bh = 0x00;
  190.  
  191.     Regs.F.Es = Seg(&cr);
  192.     Regs.F.Di = Ofs(&cr);
  193.  
  194.     Regs.F.Ds = Seg(&cc);
  195.     Regs.F.Si = Ofs(&cc);
  196.  
  197.  
  198.   MsDos(33,&Regs);
  199.  
  200.  if ((cr.id.al == 0x00) && (cr.id.ah == 0x00) && (cr.id.bl == 0x00) && (cr.id.bh == 0x00))
  201.     {
  202.        printf("%s\n",inc);
  203.        printf("This utility requires Advanced Netware to run.\n");
  204.        exit(4);
  205.     }
  206.  
  207.   Regs.F.Ax = 0xE300;
  208.   nr.Native.wl = 0x00;
  209.   nr.Native.wh = 0xFF;
  210.  
  211.   nc.Native.wl = 0x00;
  212.   nc.Native.wh = 0x05;
  213.  
  214.   Regs.F.Es = Seg(&nr);
  215.   Regs.F.Di = Ofs(&nr);
  216.  
  217.   Regs.F.Ds = Seg(&nc);
  218.   Regs.F.Si = Ofs(&nc);
  219.  
  220.   nc.func = 0x36;
  221.   nc.unique.ah = cr.id.ah;
  222.   nc.unique.al = cr.id.al;
  223.   nc.unique.bh = cr.id.bh;
  224.   nc.unique.bl = cr.id.bl;
  225.  
  226.   MsDos(33,&Regs);
  227.  
  228.   if (Regs.H.Al != 0)
  229.    {
  230.      printf("%s\n",inc);
  231.      printf("This utility requires you to be logged into the network to run.\n");
  232.      exit(3);
  233.    }
  234.  
  235.  
  236. }
  237.   /*  of Will_it_Run  */
  238.  
  239.  
  240.  
  241.  
  242. main(argc,argv)
  243. int argc;
  244. char *argv[];
  245. {
  246.  
  247. if (length(argv[1]) < 1)
  248.  {
  249.    printf("%s\n",inc);
  250.    printf("Usage: USERIS xxxxx  where xxxxx is the username to check\n");
  251.    printf("       existence of on the current file server\n");
  252.    exit(2);
  253.  }
  254.  
  255.  Will_It_Run();
  256.  
  257.  UserI(argv);
  258.  
  259. }
  260.